<template>
  <div>
    <div>
      <ul>
        <li>
          <router-link active-class="active" to="/contacts/contacts21"
            >All contacts</router-link
          >
        </li>

        <li>
          <router-link active-class="active" to="/contacts/contacts22"
            >Alice</router-link
          >
        </li>

        <li>
          <router-link active-class="active" to="/contacts/contacts23"
            >Bob</router-link
          >
        </li>
      </ul>
      <button @click="btn">随机显示</button>
      <div>
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [
        "/contacts/contacts21",
        "/contacts/contacts22",
        "/contacts/contacts23",
      ],
      i: "",
    };
  },
  methods: {
    btn() {
      this.i = Math.floor(Math.random() * 4);
      this.$router.push({ path: this.arr[this.i] });
    },
  },
};
</script>

<style>
.active {
  color: orange;
}
</style>